Skip to content

git: correctly extract tag name when commit has multiple decorations#1188

Merged
crazy-max merged 2 commits into
docker:mainfrom
lucacome:fix/git-context
Jun 30, 2026
Merged

git: correctly extract tag name when commit has multiple decorations#1188
crazy-max merged 2 commits into
docker:mainfrom
lucacome:fix/git-context

Conversation

@lucacome

Copy link
Copy Markdown
Contributor

Updated the tag reference parsing in Git.ref() to ensure the method always returns the correct tag ref even if other decorations are present.

Signed-off-by: Luca Comellini <luca.com@gmail.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max

Copy link
Copy Markdown
Member

Thanks!

I added a follow-up commit that keeps your fix for commits with multiple decorations, but avoids parsing the tag name by splitting the %D output on commas.

Git allows commas in tag names, so a decoration like HEAD, tag: release,with-comma, origin/release-branch is ambiguous if we parse the decoration string directly. The updated code asks Git for the exact tag refs pointing at HEAD with for-each-ref --points-at HEAD refs/tags/, then matches those refs against the decoration output.

I also added a regression test for a comma-containing tag name and updated the detached-tag tests for the extra Git query.

@lucacome

Copy link
Copy Markdown
Contributor Author

Cool, sounds good to me! 🙂

@crazy-max crazy-max changed the title Correctly extract tag name when commit has multiple decorations git: correctly extract tag name when commit has multiple decorations Jun 29, 2026
@crazy-max
crazy-max merged commit b9edf7d into docker:main Jun 30, 2026
116 checks passed
@lucacome
lucacome deleted the fix/git-context branch June 30, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants